<?php
$require_fields = get_fields_names('require', $module_fields);

ob_start();
foreach ($module_fields as $each_field) {
	echo "\r" . '$_[\'column_' . $each_field['name'] . '\']	= \'' . $each_field['label'] . '\';';
}
$column_fields = ob_get_clean();

ob_start();
foreach ($module_fields as $each_field) {
	echo "\r" . '$_[\'entry_' . $each_field['name'] . '\']	= \'' . $each_field['label'] . ':\';';
}
$entry_fields = ob_get_clean();

ob_start();
foreach ($module_fields as $each_field) {
	echo "\r" . '$_[\'error_' . $each_field['name'] . '\']	= \'' . $each_field['label'] . ' can\\\'t be empty!\';';
}

foreach ($module_fields as $each_field) {
	if(in_array($each_field['name'], $require_fields)&& in_array($each_field['type'], array('text_num', 'text_email', 'date', 'datetime', 'date_added', 'date_modified'))) {
		echo "\r" . '$_[\'error_invalid_' . $each_field['name'] . '\']	= \'Invalid ' . $each_field['label'] . '\';';		
	}
}
$error_fields = ob_get_clean();

$maches_arr = array (
	'/@section_name@/',
	'/@section_name_small@/',
	'/@column_fields@/',
	'/@entry_fields@/',
	'/@error_fields@/',
	
);

$replace_arr = array (
	$section_name,
	$section_name_small,
	$column_fields,
	$entry_fields,
	$error_fields,
	
);

//	preg_match_all('/@([^@]+)@/', $language_file_contents, $maches);
//	sort($maches['1']);
//	print_r(array_unique($maches['1']));

	$language_file_contents = preg_replace($maches_arr, $replace_arr, $language_file_contents);
?>